<?php
/**
 * 竞标模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;

class ProjectLog extends CommonBaseModel {
	use SoftDelete;
	// 自定义选择数据
	// 状态列表
	const STATUS_LIST = [
		0 => '已竞标',
		1 => '竞标失败',
		2 => '竞标成功',
		3 => '已作废',
	];

	protected $name = 'project_log';
	protected $autoWriteTimestamp = true;
	protected $json = ['detail'];
	protected $jsonAssoc = true;
	// 可搜索字段
	public array $searchField = ['id'];

	// 可作为条件的字段
	public array $whereField = ['project_id', 'user_id', 'status'];

	// 可作为多选条件的字段
	public array $multiWhereField = [];

	// 可做为时间
	public array $timeField = ['create_time'];

	/**
	 * 状态获取器
	 */
	public function getStatusNameAttr($value, $data) {
		return self::STATUS_LIST[$data['status']];
	}

	/**
	 * 关联
	 */
	public function project() {
		return $this->belongsTo(Project::class);
	}/**
	 * 关联用户
	 */
	public function user() {
		return $this->belongsTo(User::class);
	}

}
